#ifndef GUI_H
#define GUI_H

#include <QMainWindow>
#include "net.h"

#include <QTimer>

#include <QList>
#include <QMap>

#include <QFile>

#define GUI_MAX_LINES			2500

namespace Ui {
class gui;
}

class gui : public QMainWindow
{
	Q_OBJECT
	
public:
	explicit gui(QWidget *parent = 0);
	~gui();

private slots:
	void log_timeout();
	void clients_filter(bool on1off0);

	void slot_packet_full(log_event le);
	void slot_new_client(QString client_name);
	
	void on_b_clear_clicked();
	void on_c_n_clicked();
	void on_c_client_clicked();
	void on_c_time_clicked();
	void on_c_ffl_clicked();

	void on_f_update_clicked();
	void on_b_load_clicked();
	void on_b_host_clicked();

private:
	Ui::gui *ui;
	net n;

	QMap<QString, bool> clients;
	void append_log(log_event le);
	QList<log_event> events;
	void update_log();
	QString log_form(int index, log_event e, int msg_width);
	bool server_started;

	QTimer log_timer;

	QString file_log_name;
	QFile file_log;
	int file_lines;
	void file_append();

	int log_pos;
	bool filter_passed(log_event e);
	bool load_log(QString fn);
};

#endif // GUI_H
